home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / ANIMATE.LZH / NOISE.ASM < prev    next >
Assembly Source File  |  1984-09-14  |  2KB  |  41 lines

  1.           ; from ASSEMBLY LANGUAGE PRIMER FOR THE IBM PC & XT
  2.           ; by Robert LaFore
  3.           ;    modified to be compilable by CHASM  (disk # 37)
  4.           ;GUN--makes a machine gun sound
  5.           ;   fires fixed number of shots
  6.           ;------------------------------------------
  7. main      proc      far       ;main part of program
  8.           mov       cx,20     ;set # of shots
  9. new_shot
  10.           push      cx        ;save count
  11.           call      shoot     ;sound of shot
  12.           mov       cx,4000h  ;set up silent delay
  13. silent    loop      silent    ;silent delay
  14.           pop       cx        ;get back shots count
  15.           loop      new_shot  ;loop til done
  16.           int       20h       ;back to DOS
  17.           endp
  18.           ;------------------------------------------
  19.           ;subroutine to make brief noise
  20.           ;------------------------------------------
  21. shoot     proc      near      ;
  22.           mov       dx,140h   ;initial value of wait
  23.           mov       bx,20h    ;set count
  24.           in        al,61h    ;get port 61
  25.           and       al,0FCh   ;"and off" bits 0 and 1
  26. sound     xor       al,2      ;toggle bit #1 in al
  27.           out       61h,al    ;output to port 61
  28.           add       dx,9248h  ;add random pattern
  29.           mov       cl,3      ;get set to rotate 3 bits
  30.           ror       dx,cl     ;rotate it
  31.           mov       cx,dx     ;put it in cx
  32.           and       cx,1FFh   ;mask off upper 7 bits
  33.           or        cx,10     ;ensure not too short
  34. wait      loop      wait      ;time delay
  35.           dec       bx        ;done enough?
  36.           jnz       sound     ;if not, back to sound
  37.           and       al,0FCh   ;and off bits 0 and 1
  38.           out       61h,al    ;turn off bits o and 1
  39.           ret                 ;return from subroutine
  40.           endp
  41.           ;------------------------------------------